<template>
	<view class="zai-box">
		<image src="../../static/zaizai-login/login.png" mode='aspectFit' class="zai-logo"></image>
		<view class="zai-title">叶龄诊断APP</view>
		<view class="zai-form">
			<input class="zai-input" v-model="username" placeholder-class placeholder="请输入用户名" />
			<input class="zai-input" v-model="password" placeholder-class password placeholder="请输入密码"/>
			<button class="zai-btn" @click="logo()">立即登录</button>
		</view>
	</view>
</template>

<script>
	import {getLogin} from '../api/api.js'
	export default {
		data() {
			return {
				username:'',
				password:''
			}
			},
			methods: {
				logo(){
					if(!this.username||!this.password){
						uni.showToast({
						    title: '请输入用户名和密码',
							duration: 2000,
							icon:'none'
						});
						return
					}
					let parm={
						username:this.username,
						password:this.password,
						version:'1.0.0'
					}
					getLogin(parm,
						res=>{
							if(res.data.returnCode==200){
								 uni.setStorage({//将用户信息保存在本地
												key: 'useID',
												data: res.data.returnData.u_username
											})
								uni.setStorage({//将用户信息保存在本地
												key: 'useIDnameid',
												data: res.data.returnData.u_id
											})
								uni.setStorage({//将用户信息保存在本地
												key: 'useIDname',
												data: res.data.returnData.u_name
											})
								uni.reLaunch({url:'/pages/gcjk/gcjk'});
							}else{
								uni.showToast({
									title: res.data.returnMsg,
									duration: 2000,
									icon:'none'
								});
							}
						})
					
				}
			}
		}
</script>

<style>
	.zai-box{
		padding: 0 100upx;
		position: relative;
		margin-top: 100upx;
	}
	.zai-logo{
		width: 100%;
		width: 100%;
		height: 310upx;
	}
	.zai-title{
		position: absolute;
		top: 0;
		line-height: 360upx;
		font-size: 68upx;
		color: #fff;
		text-align: center;
		width: 100%;
		margin-left: -100upx;
	}
	.zai-form{
		margin-top: 300upx;
	}
	.zai-input{
		background: #e2f5fc;
		margin-top: 30upx;
		border-radius: 100upx;
		padding: 20upx 40upx;
		font-size: 36upx;
	}
	.input-placeholder, .zai-input{
		color: #94afce;
	}
	.zai-label{
		padding: 60upx 0;
		text-align: center;
		font-size: 30upx;
		color: #a7b6d0;
	}
	.zai-btn{
		margin-top: 100upx;
		background: #b085f9;
		color: #fff;
		border: 0;
		border-radius: 100upx;
		font-size: 36upx;
	}
	.zai-btn:after{
		border: 0;
	}
	/*按钮点击效果*/
	.zai-btn.button-hover{
		transform: translate(1upx, 1upx);
	}
	uni-page-wrapper {
        background: #fff;
 	}
</style>
